<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title>积分提现</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/common.css"/>
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
	</head>
	<body class="bg_ff">
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">积分提现</h1>
		</header>
		<div class="mui-content bg_ff">
		   <div class="padding_12 mg_top10">
			   	<div class="">
			   		<p class="color_00 bold mg_tb10">提现数额</p>
				   	<div class="tx_list">
				   		<input type="number" name="" id="integral" value="" placeholder="最小提分100" />
				   		<span class="color_00">最大</span>
				   	</div>
				   	<p class="padding_10 color_8">当前积分<span class="money"></span>,最小提分<span class="min"></span></p>
			   	</div>
		   	    
			   	<div class="">
			   		<p class="color_00 bold mg_tb10">预计到账</p>
				   	<div class="tx_list">
				   		<input type="number" name="" id="money" value="" placeholder="" />
				   		<span class="color_00">元</span>
				   	</div>
				   	<p class="padding_10 color_8">手续费<span class="poundage "></span>% ,当前手续费<span class="sxf">0</span>元</p>
			   	</div>
			   	<div class="">
			   		<p class="color_00 bold mg_tb10">输入密码</p>
				   	<div class="tx_list">
				   		<input type="password" name="" id="" value="" placeholder="请输入登录密码" />
				   	</div>
			   	</div>
			   	<div class="">
			   		<p class="color_00 bold mg_tb10">提现到</p>
				   	<div class="tx_list">
				   		<input type="text" name="" id="account" value="" placeholder="请输入提现收款账户" />
				   	</div>
			   	</div>
			   	<div class="mg_tb10 tx_chose clearfix">
			   		<div class="mui-input-row mui-radio mui-left">
			   		    <label><img src="images/pay_wx.png"/></label>
			   		    <input name="radio" type="radio" value="1" >
			   		</div>
			   		<div class="mui-input-row mui-radio mui-left">
			   		    <label><img src="images/pay_pay.png"/></label>
			   		    <input name="radio" type="radio" value="2" >
			   		</div>
			   	</div>
			   	<p class="text-center mg_top40 width90"><a href="javascript:void(0);" class="big_btn" onclick="tx()">提交</a></p>
		   </div>
		</div>
		<div class="msg-spring"></div>
		<script src="js/mui.js"></script>
		<script src="js/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
			//获取相关参数		
			function text(){
				$.ajax({
					type:"get",
					url:urlcom + "userCenter/getIntegralSet",
					async:true,
					dataType:'json',
					success:function(res){
						if(res.code==0){
							$('.poundage').text(res.data.poundage*100 )
							
							$('.min').html(res.data.withdrawalMin)//积分
						}else{
							msg(res.msg)
						}
		 			}
			     })
			}text()
			//获取我的信息
			function getUserInfoById(){
				$('.gif').show()
				$.ajax({
					type:"post",
					url:urlcom + "user/getUserInfoById",
					async:true,
					dataType:'json',
					data:{
						userId:localStorage.getItem('userId')
					},
					success:function(res){
						$('.gif').hide()
						if(res.code==0){
							$('.money').html(res.data.integral)//积分
							
							
							
							
						}else{
							msg(res.msg)
						}
		 			}
			     })
			}getUserInfoById()
			
			var sxf =''
			$('.tx_list').on('input','#integral', function(){
				var oldmoney = $('#integral').val()
				var poundage = $('.poundage').html()/100
				var newmoney = oldmoney - oldmoney*poundage
				$('#money').val(newmoney)
				sxf = oldmoney*poundage
				sxf=sxf.toFixed(2)
				$('.sxf').html(sxf)
			})

  

			
			//提现
			function tx(){
				var type = $('input:[type=radio]:checked').val()
				if(!$('#integral').val()||$('#integral').val()<100){
					msg('提现积分不正确')
					return false;
				}
				if(!$("#account").val()){
					msg('请输入提现账号')
					return false;
				}
				if(!type){
					msg('请选择提现方式')
					return false;
				}
				console.log(type)
				$.ajax({
					type:"post",
					url:urlcom + "userCenter/integralWithdrawal",
					async:true,
					dataType:'json',
					data:{
						userId:localStorage.getItem('userId'),
						integral:$('#integral').val(),
						money:$('#money').val(),
						type:type,
						poundage:sxf,
						account:$("#account").val()
					},
					success:function(res){
						$('.gif').hide()
						if(res.code==0){
							msg('申请成功')
							setTimeout(function(){
								
								mui.back()
							},1000)
							
							
							
							
						}else{
							msg(res.msg)
						}
		 			}
			     })
			}
		</script>
	</body>

</html>
